package ch.supsi.mobile.core.listeners;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.SwingUtilities;

import ch.supsi.mobile.core.Address;
import ch.supsi.mobile.core.Page;
import ch.supsi.parentalcontrol.GestioneSchedaUser;
import ch.supsi.parentalcontrol.UserPanel;

public class DoubleClick extends MouseAdapter {

	private UserPanel up;
	
	public DoubleClick(UserPanel up) {
		this.up = up;
	}
	
	@Override
	public void mouseClicked(MouseEvent me) {
		// doppio click con mouse sx
		if (me.getClickCount() == 2 && SwingUtilities.isLeftMouseButton(me)) {
			
			GestioneSchedaUser gsu = new GestioneSchedaUser(up);
			
			if(up.getType().equals("address")){
				Address a = (Address)up.getUserList().getSelectedValue();
				up.getTargetText().setText(a.getNumber());
				
			}else if(up.getType().equals("browser")){
				Page p = (Page)up.getUserList().getSelectedValue();
				up.getTargetText().setText(p.getURL());
			}
			
			gsu.testUserAction();
		}
	}

}
